/*
 * @Author: zoufengfan
 * @Date: 2022-10-13 14:25:36
 * @LastEditTime: 2022-11-01 16:31:19
 * @LastEditors: zoufengfan
 */

const TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin');

module.exports = {
  stories: ['../packages/**/*.stories.mdx', '../packages/**/*.stories.@(js|jsx|ts|tsx)'],
  addons: [
    '@storybook/addon-links',//左侧链接
    // '@storybook/addon-essentials',//属性编辑
    // '@storybook/addon-interactions',//用于组件操作回放
    "@storybook/addon-docs",//文档
  ],
  framework: '@storybook/react',
  //   babel: async (options) => {
  // // console.log(1111111111,options);
  // // options.presets.push()
  // // options.plugins.push()
  //     return options
  //   },
  webpackFinal: async (config) => {
    // 文档使用less
    config.module.rules.push({
      test: /\.less$/i,
      use: [
        // compiles Less to CSS
        'style-loader',
        'css-loader',
        {
          loader: 'less-loader',
          options: {
            javascriptEnabled: true,
          },
        },
      ],
    });

    // 解决@~等路径别名问题
    config.resolve.plugins = [
      ...(config.resolve.plugins || []),
      new TsconfigPathsPlugin({
        extensions: config.resolve.extensions,
      }),
    ];

    return config;
  },
};
